import Vue from 'vue'
import VueRouter from 'vue-router'

import Home from '../views/Home.vue'
import Rec from '../views/Rec.vue'
import MusicHall from '../views/MusicHall.vue'
import Video from '../views/Video.vue'
import Like from '../views/Like.vue'
import Latest from '../views/Latest.vue'
import Radio from '../views/Radio.vue'

// 三级路由
import Like_text from '../views/Like_text'
import Like_content from '../views/Like_content'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home,
    redirect: '/Rec',  //重定向
    children: [
      { //推荐页
        path: '/Rec',
        component: Rec
      },
      { //音乐馆
        path: '/MusicHall',
        component: MusicHall
      },
      { //视频
        path: '/Video',
        component: Video
      },
      { //电台
        path: '/Radio',
        component: Radio
      },
      { //我喜欢
        path: '/Like',
        component: Like,
        redirect: '/text',  //重定向
          // 三级路由
        children: [
          {
            name:'aaa',
            path: '/text',
            component: Like_text
          },
          {
            path: '/content',
            component: Like_content
          },
        ]
      },
      { //最近播放
        path: 'Latest',
        component: Latest
      }
    ]
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

//解决重复点击当前路由报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


export default router
